/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.dao;

import core.APersistenceManager;
import core.IGameContractDAO;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;
import persistence.GameContract;
import persistence.Team;

/**
 *
 * @author Ivan
 */
public class GameContractDAO extends APersistenceManager<GameContract> implements IGameContractDAO{

    public GameContractDAO() {
        super(GameContract.class, null);
    }

    
    @Override
    public List<Team> getTeamsByGame(int idGame) {
        
       List<Team> teams = new ArrayList<Team>();
       for (GameContract contract : findAll()) {
                int id =  contract.getGameId().getGameId().intValueExact();
                if(id == idGame){
                    Team team = contract.getTeamId();
                    team.initialize(Team.class);
                    teams.add(team);
                }                            
            }
           
       return teams;
    }
    
    
  
}
